package main

import (
	"github.com/benji/software/api"
	"github.com/benji/software/dao"
	"github.com/benji/software/middleware"
	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
)

func main() {
	r := gin.Default()
	dao.Init()
	r.Use(middleware.Cors())
	r.GET("/login_status", api.LoginStatus)
	r.POST("/signup", api.SignUp)
	r.POST("/login", api.Login)
	apis := r.Group("/api", middleware.GetLoginStatus)
	apis.GET("/question", api.GetQuestions)
	apis.POST("/answer", api.GetAnswer)
	apis.GET("/info", api.GetUserInfo)
	apis.GET("/all_history", api.GetAllHistory)
	apis.GET("/history/:id", api.GetHistory)
	apis.POST("/user/update", api.UpdateUserInfo)
	if err := r.Run(); err != nil {
		log.Errorf("Fail to start the server,err: %v", err)
	}
}
